// pages/price/info.js
import { price } from '../../api/price'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    infoArr:[
      { cname:'整车', ename:'Body Kit(Whole Vehicle)', img:'../../img/p1.png' },
      { cname:'前杠', ename:'Front Bumper Kit', img:'../../img/p2.png' },
      { cname:'后杠', ename:'Rear BUmper Kit', img:'../../img/p3.png' },
      { cname:'机盖', ename:'Hood Klt', img:'../../img/p4.png' },
      { cname:'前叶子板', ename:'Front Fender Kit(Right Only)', img:'../../img/p5.png' },
      { cname:'后叶子板', ename:'Front Fender Kit(Left Only)', img:'../../img/p6.png' },
      { cname:'车门', ename:'Rear Fender Kit(Right Only)', img:'../../img/p7.png' },
      { cname:'侧裙', ename:'Rear Fender Kit(Left Only)', img:'../../img/p8.png' },
      { cname:'车顶', ename:'Door Kit(Right Only)', img:'../../img/p9.png' },
      { cname:'后盖', ename:'Door Kit(Left Only)', img:'../../img/p10.png' },
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const { mid, sid} = options
    price({mid,sid}).then(res=>{
      console.log(res)
      let { body,font,behind,cap,front_fender_right,front_fender_left,car_door,near_fender_left,door_kit_right,door_kit_left } = res.data
      let _priceArr = [body,font,behind,cap,front_fender_right,front_fender_left,car_door,near_fender_left,door_kit_right,door_kit_left]
      let _info = this.data.infoArr
      _info.map((item,index)=>{
          item.price = _priceArr[index]
          return item
      })
      this.setData({ infoArr:_info })
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})